<template>
	<view>
		<view class="robotMessage"  @tap="showInfo(item.problemResult,item.problemAbstract,item.id,item.detailType)" > 
			<image class="image" src="/static/img/robot.png" mode=""></image>
			<view class="doublec" @tap="showChatMessageInfo(item.resultType,item.chatInfoList)" >
				<!-- <rich-text type ="text" space=" " :preview="true" :nodes="'<p>'+item.problemResult+'</p>'"></rich-text> -->
				<text class="left-message"  >{{removeBetweenAtSymbols(item.problemResult)}}</text>
				<text class="left-message-more" v-if="item.resultType='1' &&  item.chatInfoList != null &&  item.chatInfoList.length > 0  "  >点击查看参考信息</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"rebotTextMessage",
		props:{
			item :{
				type:Object,
				require:true,
				default:{}
			},
		},
		data() {
			return {
				
			};
		}, 
		methods:{
			showInfo(problemResult,problemAbstract,id,detailType) {
				//查看消息详情信息 
				if(detailType == 'text'){ 
					uni.navigateTo({
						url:'/pages/robot/messageInfo',
						success: (res) => {
							res.eventChannel.emit('updatePageData',{ data:'', title: problemAbstract ,content: problemResult })
						}
					})
				} else if(detailType == 'page'){
					//提取消息跳转页面 截取两个@@之间的跳转路径信息
					let  pagePath = this.extractBetweenAtSymbols(problemResult);
					uni.navigateTo({
						url: pagePath + '&detail=true' 
					})
				}
			},
			extractBetweenAtSymbols(str) {
				if(str == null ){
					return str;
				}
			    const match = str.match(/@(.*?)@/);
			    return match ? match[1] : str;
			},
			removeBetweenAtSymbols(str) {
				if(str == null ){
					return str;
				} 
			    return str.replace(/@.*?@/g, '');
			},
			showChatMessageInfo(resultType,chatInfoList) {
				if(resultType != '1' ){
					return;
				} 
			    uni.navigateTo({
			    	url:'/pages/robot/chatResultInfo',
			    	success: (res) => {
						res.eventChannel.emit('updatePageData',{ data:chatInfoList })
			    	}
			    })
			}
		}
	}
</script>

<style lang="scss" > 
	.robotMessage {
		display: flex;
		align-items: flex-start;
		flex-direction: row;
		justify-content: flex-start;
		
		.image {
			width: 59rpx;
			height: 50rpx;
			margin: 0 14rpx 0 0;
		}
		
	}
	.doublec {
		margin: 0;
		border-radius: 14rpx;
		background-color: white;
		border: 2rpx solid rgba(187, 187, 187, 0.5294117647);
		padding: 10 30rpx;
		margin-bottom: 30rpx;
		max-width: 600rpx;
		// max-width: 600rpx;
		/* overflow: hidden; */

		.left-message {
			font-size: 18rpx;
			font-family: AppleColorEmoji;
			color: #000;
			white-space: nowrap;
			text-overflow: ellipsis;
			max-width: 500rpx;
			margin: 0;
			border-radius: 14rpx;
			/* overflow: hidden; */
		}
	}
	
	.load-more{
		font-size: 16rpx;
		color: '#c6c6c6';
		text-align: center;
		padding: 10px 0px;
	}
	.left-message-more{
		font-size: 16rpx;
		color: '#4482f4';
		text-align: center;
		padding: 10px 0px 0px 0px;
	}
</style>